package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.StringTokenizer;

public class P1077 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1077.class.getResource("P1077.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		StringBuffer sb= new StringBuffer("");
		String line = stdin.readLine();
		State object = new State("1 2 3 4 5 6 7 8 x");
		while (line != null && line.trim().length() > 0) {
			State state = new State(line);
			State result = find(state, object);
			if (result == null) {
				sb.append("unsolvable");
			} else {
				StringBuffer t = new StringBuffer("");
				while (result.parent != null) {
					t.append(result.step);
					result = result.parent;
				}
				t.reverse();
				sb.append(t);
			}
			line = stdin.readLine();
		}
		System.out.println(sb.toString());
	}

	private static State find(State state, State object) {
		
		Set<State> cache = new HashSet<State>();
		cache.add(state);
		LinkedList<State> queue = new LinkedList<State>();
		queue.addLast(state);
		
		while (!queue.isEmpty()) {
			State s = queue.pollFirst();
			for (State t: new State[] {s.down(), s.up(), s.left(), s.right()}) {
				if (t != null) {
					if (t.equals(object)) {
						return t;
					} else {
						if (!cache.contains(t)) {
							cache.add(t);
							queue.addLast(t);
						}
					}
				}
			}
		}
		return null;
	}
	
	private static class State {
		
		char[][] s;
		int c, r;	//current postion
		char step;
		State parent;

		public State() {
			this.s = new char[3][];
			for (int i = 0; i < 3; i ++) {
				this.s[i] = new char[3];
			}
			this.r = -1;
			this.c = -1;
			this.step = ' ';
			this.parent = null;
		}
		
		public State(String str) {
			
			this.s = new char[3][];
			StringTokenizer st = new StringTokenizer(str);
			for (int i = 0; i < 3; i ++) {
				this.s[i] = new char[3];
				for (int j = 0; j < 3; j ++) {
					this.s[i][j] = st.nextToken().charAt(0);
					if ('x' == this.s[i][j]) {
						this.r = i;
						this.c =j;
					}
				}
			}
			this.step = ' ';
			this.parent = null;
		}
		
		public int hashCode() {
			return this.toString().hashCode();
		}
		
		public boolean equals(Object obj) {
			if (obj == null || !(obj instanceof State)) {
				return false;
			} else {
				State state = (State)obj;
				for (int i = 0; i < 3; i ++) {
					for (int j = 0; j < 3; j ++) {
						if (this.s[i][j] != state.s[i][j]) {
							return false;
						}
					}
				}
				return true;
			}
		}
		
		public String toString() {
			StringBuffer sb = new StringBuffer("");
			for (int i = 0; i < 3; i ++) {
				for (int j = 0; j < 3; j ++) {
					sb.append(this.s[i][j]);
				}
				sb.append("\n");
			}
			return sb.toString();
		}
		
		private State move(char step, int dx, int dy) {
			State n = null;
			if (this.r + dy <= 2 && this.r + dy >= 0 
					&& this.c + dx <= 2 && this.c + dx >= 0) {
				n = new State();
				for (int i = 0; i < 3; i ++) {
					for (int j = 0; j < 3; j ++) {
						n.s[i][j] = this.s[i][j];
					}
				}
				n.r = this.r + dy;
				n.c = this.c + dx;
				n.s[n.r][n.c] = this.s[this.r][this.c];
				n.s[this.r][this.c] = this.s[n.r][n.c];
				n.step = step;
				n.parent = this;
			}
			return n; 
		}
		
		public State down() {
			return move('d', 0, 1);
		}
		public State up() {
			return move('u', 0, -1);
		}
		public State left() {
			return move('l', -1, 0);
		}
		public State right() {
			return move('r', 1, 0);
		}
	}
}
